package com.baidu.bos.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baidu.bos.dao.IStaffDao;
import com.baidu.bos.domain.Staff;
import com.baidu.bos.service.IStaffService;
import com.baidu.bos.utils.PageBean;

@Service
@Transactional
public class StaffServiceImpl implements IStaffService {
	@Resource
	private IStaffDao staffDao;
	
	public void save(Staff model) {
		model.setDeltag("0");
		if (model.getHaspda() == null) {
			model.setHaspda("0");
		}
		staffDao.save(model);
	}

	public void pageQuery(PageBean pageBean) {
		staffDao.pageQuery(pageBean);
	}

	public void delete(String ids) {
		String[] sids = ids.split(",");
		for (String id : sids) {
			Staff staff = staffDao.findById(id);
			staff.setDeltag("1");
		}
	}

	public void update(Staff model) {
		Staff staff = staffDao.findById(model.getId());
		staff.setName(model.getName());
		staff.setTelephone(model.getTelephone());
		staff.setStation(model.getStation());
		staff.setStandard(model.getStandard());
		if (model.getHaspda() == null) {
			staff.setHaspda("0");
		}else {
			staff.setHaspda(model.getHaspda());
		}
		
	}

	public List<Staff> findByContidion(DetachedCriteria dc) {
		return staffDao.findByCriteria(dc);
	}
}
